import os
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from application.config import BaseConfig

# from applications.common.script import init_script
from application.extensions import init_plugs

from application.api import init_bps

from application.ws import init_ws

def create_app():
    app = Flask(os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))

    # 引入配置
    app.config.from_object(BaseConfig)

    # 注册插件
    init_plugs(app)

    # # 注册蓝图
    init_bps(app)

    # # 注册命令
    # init_script(app)

    # 启动 websocket 服务
    init_ws(app)

    return app
